#!/usr/bin/python

import os
import sys

class Configuration():
    '''
        configurate the zcnote
    '''
    def __init__(self):
        self.config_path = '~/.zcnote/config'

    def isFirstStart(self):
        if os.path.exists(self.config_path):
            return False
        else:
            return True

    def isBroken(self):
        with open(self.config_path, 'r') as fobj:
            for line in fobj:
                if 'config end' in line:
                    return False
        print("The Configuration File is Broken!")
        return True

    def doWhenFirstStart(self):
        print("Do What zcnote First Start Do")
        os.mkdir('~/.zcnote')
        with open(self.config_path, 'w') as fobj:
            fobj.write('config end')
            fobj.write('\n')

    def get(self):
        pass

    def set(self):
        pass

    def update(self):
        pass

    def run(self):
        if self.isFirstStart():
            self.doWhenFirstStart()
        if self.isBroken():
            self.doWhenFirstStart()


if __name__ == "__main__":
    config = Configuration()
    config.run()
    
